package com.atsansan.mywork.login.service.impl;

import com.atsansan.mywork.login.dao.CourseraDao;
import com.atsansan.mywork.login.entity.BookEntity;
import com.atsansan.mywork.login.entity.CourseraEntity;
import com.atsansan.mywork.login.service.CourseraService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author sansan
 * @create 2021-03-12 17:46
 */
@Service("couseraService")
public class CourseraServiceImpl extends ServiceImpl<CourseraDao, CourseraEntity> implements CourseraService {

    @Override
    public List<CourseraEntity> list() {
        List<CourseraEntity> courseraEntities=baseMapper.selectList(null);
        return courseraEntities;
    }

    @Override
    public List<CourseraEntity> listByKey(String key) {
        QueryWrapper<CourseraEntity> queryWrapper=new QueryWrapper<>();
        if(!StringUtils.isEmpty(key)){
            queryWrapper.and((obj)->{
                obj.eq("c_level",key).or().like("c_level",key);
            });
            return baseMapper.selectList(queryWrapper);
        }
        return null;
    }

}
